package sprintServer.start;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import sprintServer.dbconnect.Conn;

public class ServerJoin {
	StringBuffer sql = new StringBuffer();
	Connection con ;
	PreparedStatement pstmt;
	
	public String join(String id, String pass){
		String result="flase";
		
		sql.append("insert into member (");
		sql.append("id");
		sql.append(",pass");
		sql.append(",state");
		sql.append(",friendId");
		sql.append(") values (");
		sql.append("?");
		sql.append(",?");
		sql.append(",?");
		sql.append(",?");
		sql.append(")");
		try{
			con = Conn.getConnection();
			pstmt = con.prepareStatement(sql.toString());
			pstmt.setString(1, id);
			pstmt.setString(2, pass);
			pstmt.setInt(3, 0);
			pstmt.setString(4,"none");
			int a = pstmt.executeUpdate();
			if(a > 0){
				result = "succes";
			}else{
				result ="false";
			}
		
			
		}catch(SQLException se){
			System.out.println("DB접속에러"+se.toString());
		}
		finally{
			try{if(pstmt != null)pstmt.close();}catch	(SQLException se1){}
			try{if(con != null)con.close();}catch	(SQLException se1){}			
		}
		return result;
	}
}
